package com.lanyou.cook.camel.util;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 将异常保存至字符串
 * @author ly-lihailang
 *
 */
public class ExceptionToStrFactory {
	/**
	 * @param e 异常Exception
	 * @return 将异常转化为成的字符串
	 */
	public static String getErrorInfoFromException(Exception e) {
		try {
			StringWriter sw = new StringWriter();
			PrintWriter pw = new PrintWriter(sw);
			e.printStackTrace(pw);
			return "\r\n" + sw.toString() + "\r\n";
		} catch (Exception e2) {
			return "bad getErrorInfoFromException";
		}
	}

}
